package com.jnzc.ocr.rest.app.shop.controller.app;

import com.google.common.collect.Lists;
import com.jnzc.ocr.common.vo.UserVo;
import com.jnzc.ocr.dependencies.rest.base.BaseController;
import com.jnzc.ocr.rest.app.shop.param.app.AppOrderRechargeSaveParam;
import com.jnzc.ocr.serv.shop.api.ShopOrderRechargeApi;
import com.jnzc.ocr.serv.shop.entity.ShopOrder;
import com.jnzc.ocr.serv.shop.entity.ShopOrderRecharge;
import com.jnzc.ocr.serv.shop.vo.ShopOrderRechargeCreateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangcm
 * @version 1.0, 2017-10-06
 */
@Api(tags = {"app - 店铺订单充值表接口"})
@RestController
@RequestMapping("/app/shopOrderRecharge")
public class AppOrderRechargeController extends BaseController {

    @Autowired
    private ShopOrderRechargeApi shopOrderRechargeApi;

    @ApiOperation(value = "生成")
    @PostMapping("")
    public ShopOrder create(@RequestBody AppOrderRechargeSaveParam param){
        UserVo userVo = super.get();
        ShopOrderRechargeCreateVo createVo = new ShopOrderRechargeCreateVo();
        ShopOrder order = new ShopOrder();
        order.setShopId(userVo.getShopId());
        order.setMemberId(param.getMemberId());
        order.setUserId(userVo.getId());
        order.setUserName(userVo.getName());
        createVo.setOrder(order);
        ShopOrderRecharge recharge = new ShopOrderRecharge();
        recharge.setRechargeAmount(param.getRechargeAmount());
        createVo.setRecharge(recharge);
        return shopOrderRechargeApi.create(createVo);
    }

}
